#!groovy
import org.devops.tools;

def call(def data){

    tools.PrintMes("部署",'green')
    
    sh("wget ${data.nexus_url}")
    def remote = [:]
    remote.name = 'test'
    remote.host = "${data.target_host}"
    remote.user = "${data.target_user}"
    remote.password = "${data.target_password}"
    remote.allowAnyHosts = true
    writeFile file: 'start.sh', text: '''
    "${data.script}"
    '''
    //上传制品
    sshPut remote: remote, from: "${params.product_name}", into: "${params.target_dir}" 
    //上传执行脚本
    sshPut remote: remote, from: "start.sh", into: "${params.target_dir}" 
    //执行命令
    sshCommand remote: remote, command: "cd ${params.target_dir} && bash start.sh"

}